$(document).ready(function () {
    // var url1=$("*[name='url']").val();
    // alert("url1|"+url1);
    var url=GetQueryString("url");
    var accordion=$("#accordion");
    $.ajax({
        type:"get",
        url:"/myCode/getAnswer",
        data:{
            url:url
        },
        dataType:"json",
        success:function (data) {
            if(data==null){
                alert("你今天没有提交作业哟！！");
            } else{
                for(var i in data) {
                    if(i==0){
                        accordion.append("<div class='panel panel-default'>" +
                            "<div class='panel-heading'><h4 class='panel-title'><a data-toggle='collapse' data-parent='#accordion' href='#collapse"+i+"'>"
                            + data[i].name + "</a></h4></div>" + "<div id='collapse"+i+"' class='panel-collapse collapse in'>" +
                            " <div class='panel-body'>" + data[i].answer + "</div> </div></div>");
                    }else{
                        accordion.append("<div class='panel panel-default'>"+
                        "<div class='panel-heading'><h4 class='panel-title'><a data-toggle='collapse' data-parent='#accordion' href='#collapse"+i+"'>"
                        +data[i].name+"</a></h4></div>"+"<div id='collapse"+i+"' class='panel-collapse collapse'>"+
                        "<div class='panel-body'>"+ data[i].answer +"</div> </div></div>")
                    }
                }
            }
            
        }
    })
    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if(r != null) return decodeURI(r[2]);
        return null;
    }
})
